﻿using System;
using System.IO;
using System.Collections.Generic;

namespace _12_12作业
{
    class Program
    {
        static void Main(string[] args)
        {
            string path = @"D:\";
            List<string> listFile = new List<string>();
            List<string> listDirec = new List<string>();
            GetAllFiles(path,listFile,listDirec);
            foreach (var item in listFile)
            {
                Console.WriteLine(item);
            }
            foreach (var item in listDirec)
            {
                Console.WriteLine(item);
            }
        }

        static void GetAllFiles(string path,List<string> listFile,List<string> listDirec)
        {
            try
            {
                string[] strFile = Directory.GetFiles(path);
                string[] strDirec = Directory.GetDirectories(path);
                foreach (var item in strFile)
                {
                    listFile.Add(item);
                }
                foreach (var item in strDirec)
                {
                    listDirec.Add(item);
                }

                if (strDirec.Length > 0)
                {
                    foreach (var item in strDirec)
                    {
                        GetAllFiles(item, listFile, listDirec);
                    }
                }
            }
            catch
            {

            }
            
        }
    }
}
